{template 'common/header'}
<ul class="nav nav-tabs">
	<li{if $do == 'dianyuan'} class="active"{/if}><a href="{php echo $this->createWebUrl('dianyuan')}">功能说明</a></li>
	<li{if $do == 'dianyuangl'} class="active"{/if}><a href="{php echo $this->createWebUrl('dianyuangl')}">店员管理</a></li>
	<li{if $do == 'dianyuanadd'} class="active"{/if}><a href="{php echo $this->createWebUrl('dianyuanadd',array('op'=>'add'))}">{if $id > 0}编辑店员{else}添加店员{/if}</a></li>
    <li{if $do == 'hexiao'} class="active"{/if}><a href="{php echo $this->createWebUrl('hexiao')}">核销记录</a></li>
</ul>
{if $do == 'dianyuangl'}
<div class="main">
<div class="main table-responsive">
	<div class="alert alert-warning" role="alert">
		注意：店员的名称和消费密码均不能有重复。
	</div>
	<form method="post" class="form-horizontal" id="form1">
		<div class="panel panel-default">
			<div class="panel-body table-responsive">
				<table class="table table-hover">
					<thead class="navbar-inner">
					<tr>
						<th>店员姓名</th>
						<th>所在门店</th>
						<th>微信昵称</th>
						<th>手机号</th>
						<th>消费密码</th>
						<th>操作</th>
					</tr>
					</thead>
					<tbody id="list">
					{loop $list $item}
					<tr>
						<td>{$item['ename']}</td>
						<td>{$item['companyname']}</td>
						<td>{$item['nickname']}</td>
						<td>{$item['tel']}</td>
						<td>{$item['password']}</td>
						<td>
							<a href="{php echo $this->createWebUrl('dianyuanadd',array('id'=>$item['id'],'op'=>'edit'))}" title="编辑">编辑</a>&nbsp;-&nbsp;
							<a href="{php echo $this->createWebUrl('dianyuandel',array('id'=>$item['id']))}" onclick="return confirm('此操作不可恢复，确认删除？');return false;" title="删除">删除</a>
						</td>
					</tr>
					{/loop}
					</tbody>
				</table>
			</div>
		</div>
		{$pager}
	</form>
</div>
</div>
{/if}
{if $do == 'dianyuanadd'}
<div class="alert alert-info">
	<h4><i class="fa fa-info-circle"></i> 店员说明</h4>
	<p style="color:#ff0000">添加微信店员密码是唯一的，不可以重复</b><br>
	
</div>
<div class="clearfix">
	<form class="form-horizontal form" id="form1" action="{php echo $this->createWebUrl('dianyuanadd',array('op'=>'adde'))}" method="post" enctype="multipart/form-data">
		<div class="panel panel-default">
			<div class="panel-heading">{if $id > 0}编辑店员{/if}{if empty($id)}添加店员{/if}</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>所属门店</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="companyname" value="{$clerk['companyname']}" class="form-control">
						<div class="help-block">请选择店员所在分店名称</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>店员姓名</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="ename" value="{$clerk['ename']}" class="form-control">
						<div class="help-block">请填写店员姓名，姓名不能重复</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>密码</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="password" value="{$clerk['password']}" class="form-control">
						<div class="help-block">请输入密码,密码不能重复</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>手机号</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="tel" value="{$clerk['tel']}" class="form-control">
						<div class="help-block">店员联系使用</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>店员微信昵称</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="nickname" value="{$clerk['nickname']}" class="form-control">
						<div class="help-block">请填写微信昵称</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>店员粉丝编号</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="openid" value="{$clerk['openid']}" class="form-control">
						<div class="help-block">请填写微信编号（粉丝营销->粉丝->找到对应的店员->查看详情->粉丝编号复制到这里）</div>
					</div>
				</div>
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input name="submit" id="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
			<input type="hidden" name="token" value="{$_W['token']}" />
            <input type="hidden" name="id" value="{$clerk['id']}" />
		</div>
	</form>
</div>
<script>
	$('#submit').click(function(){
		var ename = $.trim($(':text[name="ename"]').val());
		if (!ename) {
			util.message('请填写店员名称');
			return false;
		}
		var password = $.trim($(':text[name="password"]').val());
		if (!password) {
			util.message('请填写店员密码');
			return false;
		}
		var tel = $.trim($(':text[name="tel"]').val());
		if (!tel) {
			util.message('请填写店员手机号');
			return false;
		}
		var phone = /^\d{11}$/;
		if(!phone.test(tel)) {
			util.message('请填写正确的手机格式');
			return false;
		}
	});
</script>
{/if}
{template 'common/footer'}